﻿Partial Class frmInicio
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            Session("NameUser") = "Nuevo"
            Session("Estado") = "I"
        End If
    End Sub

    Protected Sub lkbLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogin.Click
        TextBox7.Text = Nothing
        Me.MP_Login.Show()
    End Sub

    Protected Sub lkbNuevousuario_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbNuevousuario.Click
        LimpiarF2()
        Me.MP_Registrar.Show()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.MP_Registrar.Hide()
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        lblestado.Text = "A"
        Session("NameUser") = txtemail.Text
        lblNombre.Text = "Bienvenido: " & Session("NameUser").tostring
        txtemail.Text = Nothing
        txtPass2.Text = Nothing
        txtPass.Text = Nothing
        txtNomCli.Text = Nothing
        txtdni.Text = Nothing
        txtbreve.Text = Nothing
        Me.mp_registrar.hide()
    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.MP_Login.Hide()
        If TextBox7.Text.Trim = Session("NameUser").ToString.Trim Then
            lblestado.Text = "A"
            lblNombre.Text = "Bienvenido: " & Session("NameUser").ToString

        Else
            lblestado.Text = "I"
            lblNombre.Text = "Usuario no registrado"

            Me.MP_Registrar.Show()
        End If



    End Sub

    Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.MP_Login.Hide()
    End Sub

    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        If "I" = "I" Then
            lblNombre.Text = ""
            'Dim fechaReserva As Date
            'Dim fechaDevolucion As Date
            'Dim dias As Integer

            'fechaReserva = Format(CDate(Replace(txtfechareserva.Text, ".", "/")), "mm/dd/yyyy")
            'fechaDevolucion = Date.ParseExact(txtFechaDevolucion.Text, "dd/MM/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)

            'dias = (fechaDevolucion - fechaReserva).TotalDays

            If txtfechareserva.Text = "11/13/2014" Then
                lblMsgForm.Text = "Cantidad de días de alquiler menor a la permitida. Aumente el rango"

            ElseIf txtfechareserva.Text = "11/10/2014" Then
                lblMsgForm.Text = "Vehículo no disponible en fechas solicitadas. Seleccione otro vehículo"

            Else
                lblNombre.Text = "Reserva Nro 002341 realizada en las fechas indicadas"
                Me.MP_Detalle.Hide()
            End If
        Else
            lblNombre.Text = "Usuario no registrado"
            Me.MP_Registrar.Show()
            Me.MP_Detalle.Hide()
        End If

    End Sub

    Protected Sub lbnVer1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbnVer1.Click
        Me.MP_Detalle.Show()
        Llenardetalle(1)
    End Sub

    Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
        lblMsgForm.Text = ""
        Me.MP_Detalle.Hide()
    End Sub

    Public Sub Llenardetalle(ByVal num As Integer)

        If num = 1 Then
            lblCodigo.Text = "0025585266"
            lbltipoAuto.Text = "Toyota Yaris"
            lblPrecio.Text = "40"
            imgdetalle.ImageUrl = "~/Resourse/AU_001.PNG"
        Else
            If num = 2 Then
                lblCodigo.Text = "00265588266"
                lbltipoAuto.Text = "Hyundai H1"
                lblPrecio.Text = "70"
                imgdetalle.ImageUrl = "~/Resourse/AU_002.PNG"
            Else
                If num = 3 Then
                    lblCodigo.Text = "0025699966"
                    lbltipoAuto.Text = "Susuki Gran Nomade"
                    lblPrecio.Text = "80"
                    imgdetalle.ImageUrl = "~/Resourse/AU_003.PNG"
                Else
                    lblCodigo.Text = "0025596636"
                    lbltipoAuto.Text = "toyota Hilux"
                    lblPrecio.Text = "90"
                    imgdetalle.ImageUrl = "~/Resourse/AU_004.PNG"
                End If
            End If
        End If
        LimpiarF1()
    End Sub

    Public Sub LimpiarF1()
        txtFechaDevolucion.Text = ""
        txtfechareserva.Text = ""
        ddlcentrega.SelectedValue = 0
        ddlcdevolucion.SelectedValue = 0
    End Sub

    Public Sub LimpiarF2()
        txtbreve.Text = ""
        txtdireccion.Text = ""
        txtNomCli.Text = ""
        txtPass.Text = ""
    End Sub

    Protected Sub lbnVer2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbnVer2.Click
        Me.MP_Detalle.Show()
        Llenardetalle(2)
    End Sub

    Protected Sub lbnVer3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbnVer3.Click
        Me.MP_Detalle.Show()
        Llenardetalle(3)
    End Sub

    Protected Sub lbnVer4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbnVer4.Click
        Me.MP_Detalle.Show()
        Llenardetalle(4)
    End Sub
End Class